﻿using System.Windows.Controls;
using Kindohm.KSynth.Library;
using System.Windows.Media;
using System.Windows;

namespace Kindohm.KSynth.AudioCanvas
{
    public partial class VolumeControl : UserControl, ICanvasControl
    {
        Attenuator attenuator;

        public VolumeControl()
        {
            InitializeComponent();
            this.ShowPrompt();
        }

        public TranslateTransform Translation
        {
            get { return this.translation; }
        }
        
        public Attenuator Attenuator
        {
            get { return this.attenuator; }
            set
            {
                this.attenuator = value;
                this.attenuator.SetAttenuation(this.volumeSlider, Slider.ValueProperty);
            }
        }

        private void HyperlinkButton_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            this.line.Visibility = Visibility.Collapsed;
            this.infoBox.Visibility = Visibility.Collapsed;
            Prompts.ShowVolume = false;
        }

        void ShowPrompt()
        {
            if (Prompts.ShowVolume)
            {
                this.line.Visibility = Visibility.Visible;
                this.infoBox.Visibility = Visibility.Visible;
                Prompts.ShowVolume = false;
            }
            else
            {
                this.line.Visibility = Visibility.Collapsed;
                this.infoBox.Visibility = Visibility.Collapsed;
            }
        }
    }
}
